package grpcClient

import (
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	. "zimuzu_cvn_web_api/pkg/e"
)

type RpcClient struct {
	Conn          *grpc.ClientConn
	CvnClient     CvnServiceClient
	UsdtClient    UsdtServiceClient
	AddressClient AddressServiceClient
}

var rpcClient RpcClient

func InitClient(conn *grpc.ClientConn) {
	rpcClient.Conn = conn
	rpcClient.CvnClient = NewCvnServiceClient(rpcClient.Conn)
	rpcClient.UsdtClient = NewUsdtServiceClient(rpcClient.Conn)
	rpcClient.AddressClient = NewAddressServiceClient(rpcClient.Conn)
}

//Cvn-生成账户签名
func CvnAmountCreate(data map[string]string) (*CreateResponse, error) {
	var request Request
	request.Data = data
	return rpcClient.CvnClient.AmountCreate(context.Background(), &request)
}

//Cvn-校验账户签名
func CvnAmountCheck(data map[string]string) (response *CheckResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.CvnClient.AmountCheck(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Cvn-生成日志签名
func CvnLogCreate(data map[string]string) (response *CreateResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.CvnClient.LogCreate(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Cvn-校验日志流水签名
func CvnLogListCheck(data map[string]string) (response *CheckListResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.CvnClient.LogListCheck(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Usdt-生成账户签名
func UsdtAmountCreate(data map[string]string) (response *CreateResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.UsdtClient.AmountCreate(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Usdt-校验账户签名
func UsdtAmountCheck(data map[string]string) (response *CheckResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.UsdtClient.AmountCheck(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Usdt-生成日志签名
func UsdtLogCreate(data map[string]string) (response *CreateResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.UsdtClient.LogCreate(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Usdt-校验日志流水签名
func UsdtLogListCheck(data map[string]string) (response *CheckListResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.UsdtClient.LogListCheck(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Address-校验地址签名
func AddressCheck(data map[string]string) (response *CheckResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.AddressClient.AddressCheck(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}

//Address-生成地址签名
func AddressCreate(data map[string]string) (response *CreateResponse, err error) {
	var request Request
	request.Data = data
	response, err = rpcClient.AddressClient.AddressCreate(context.Background(), &request)
	if err != nil {
		Log("err", err)
	}
	return
}
